<script type="text/javascript">
	$(document).ready(function(){
		
		$('#penjualanid').val('<%= @penjualan.id.to_s %> ')
			
		$('input#barcodescan').focus();
	
		$('#barcodescan').bind('keypress', function(e) {
			if(e.keyCode==13){
				$.ajax({
				  data: {barcodescan: $('#barcodescan').val(), penjualanid: $('#penjualanid').val()},
				  method: "get", 
				  url: '<%= j url_for(:controller => "penjualan_subs", :action => "add_row") %>',
				  success: function(data) {
				  }
				});
			}else if(e.charCode==43){
					$('input#jumlah').val('');
					$('#myModal').modal('show');			
					$('h3#myModalLabel').html('Total Belanja');
					$('.modal-body').html(' <%= j render partial: "form_pembayaran" %> ');
					$('input#jumlah').blur();
					total_harga = $("input#total_pembayaran").val();
					$('#total_biaya h1').html(' Rp.'+total_harga+'')
					setTimeout(function() {
						$('input#cash').val('');
						$('input#cash').focus();
					}, 500);
				}		
		});
		
		$("#modal-btn1").click(function(){
			$('#myModal').modal('show');
		});
		
		$('input#cash').bind('keypress', function(e){
			if(e.keyCode==13){
				alert('haii');		
			}
		});
		
	});
	
</script>

<!-- Button to trigger modal -->

<div class="row-fluid">

	<div class="span12">

		<div class="widget_wrapper" style="padding-bottom:20px; min-height: 650px;">

			<div class="widget_header">
				<h3 class="icos_lock">jumlah pembelian</h3>
			</div>

			<div class="widget_content no-padding">
				<div class="form_inputs clearfix">
					<div class="row-fluid">
						<div class="span6">
							<%= label_tag "Barcode",nil, :class => "span1", style: "padding-top:5px;margin-right:25px;" %>
							<%= text_field_tag	"barcodescan", nil, :class => "span7", style: "margin-left:-20px;" %>
						</div>
							<%= text_field_tag "close",nil, :style => "width:5px;display:none;"  %>
							<%= text_field_tag "penjualanid",@penjualan.id, :style => "width:30px;" %>
						<div class="span3 legend">
							<div class="test" style="margin-top:-15px;">
								Total
							</div><br />
							<div id="total_harga" class="test" style="margin-top:-20px;">
								
							</div>	
							<%= text_field_tag "total_pembayaran",nil, :style => "display:none" %>							
						</div>
					</div>
				</div>
			</div>
			
		<div class="separator" style="margin-top:0px;"></div>	
		<!-- Tabel pembelian barang -->
			
			<div class="widget_content no-padding">
				<div class="highligts_content">
					<div class="container-fluid">
						<table width="100%" cellspacing="0" cellpadding="0" class="default_table bordered">
						<thead class="" >
							<tr class="">
									<td width="50%">Nama Barang</td>
									<td width="10%">Jml</td>
									<td width="20%">Harga</td>
									<td width="20%">Total</td>
							</tr>
						</thead>
						<tbody id="daftar_penjualan">
							<tr id="empty-row">
									<td>none</td>
									<td>none</td>
									<td class="text-right">none</td>
									<td class="text-right">none</td>
							</tr>
						</tbody>
						</table>
					</div>
				</div>
			</div>
			
			<!-- end tabel pembelian barang -->	
			
		</div>
	</div>
</div>



		
